﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace Kugar.UI.WinForm
{
    public class NumericUpDownExControlDesinger : ControlDesigner
    {
        public override DesignerActionListCollection ActionLists
        {
            get
            {
                DesignerActionListCollection collection = new DesignerActionListCollection();

                collection.Add(new NumericUpDownExActionList(this.Component, this));
                return collection;
            }
        }
    }

    public class NumericUpDownExActionList : DesignerActionList
    {
        private DesignerActionUIService _service;
        private NumericUpDownExControlDesinger _designer;

        public NumericUpDownExActionList(IComponent component, NumericUpDownExControlDesinger designer)
            : base(component)
        {
            this._designer = designer;
            this._service = component.Site.GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;
            this.AutoShow = true;
        }

        public override DesignerActionItemCollection GetSortedActionItems()
        {
            var item = new DesignerActionItemCollection();

            item.Add(new DesignerActionHeaderItem("功能"));

            item.Add(
                    new DesignerActionPropertyItem("MaxValueControl",
                     "最大值控件", "功能",
                     "设置关联的最大值控件"));

            item.Add(
                     new DesignerActionPropertyItem("MinValueControl",
                                                    "最小值控件", "功能",
                                                    "设置关联的最小值控件"));

            return item;
        }


        public NumericUpDownEx SourceControl
        {
            get { return (NumericUpDownEx)this.Component; }
        }

        public NumericUpDown MaxValueControl
        {
            get { return SourceControl.MaxValueControl; }
            set
            {
                SourceControl.MaxValueControl = value;
                this._service.Refresh(this.Component);
            }
        }

        public NumericUpDown MinValueControl
        {
            get { return SourceControl.MinValueControl; }
            set
            {
                SourceControl.MinValueControl = value;
                this._service.Refresh(this.Component);
            }
        }
    }
}
